<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>现金卡面值列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
    <!--{include file="comm/icheck.tpl"}-->
    <!--{include file='comm/comm_pic.tpl'}-->
</head>
<body>

<div class="container">
    
    <div class="comm_content">

        <table id="flex" style="display:none"></table>

    </div>

</div>

<!---新增代金卡弹出框start-->
<div id="pop" style="display: none;">

    <div class="panel">

        <div class="panel-body">

            <form id="item_form" onsubmit="return false;" class="form-horizontal">

                    <label class="col-sm-4 control-label" for="face_value" style="margin-top: 10px;">
                        <span class="red">*</span>
                        代金卡类型：
                    </label>
                    <div class="col-sm-8" style="margin-top: 10px;">
                        <input type="text" class="form-control w160" placeholder="请输入代金卡类型"  id="card_type" name="card_type" />
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>

<script>
$("#flex").flexigrid({
    url:"/invokingAjax-backend/company/cardType.ajax?operFlg=1",
    dataType: "json",
    colModel : [
        {display: "操作", width : 100, align:"center"},
        {display: "类型编号", name : "card_type_id", width : 80,align:"left"},
        {display: "类型名称", name: "card_type_name", width : 150,align:"left"}
    ],
    buttons : [
        {name: "添加", bclass: "add", onpress : "cardType.edit.open"}
    ],
    usepager: true,
    rp: 10,
    useRp: true,
    showTableToggleBtn: true,
    onSubmit: function() {
        var dt = $('#search_form').serializeArray();
        $("#flex").flexOptions({params: dt});
        return true;
    }
});

var cardType ={



    //添加或修改代金卡
    edit: {

        open: function( ) {

            E.popup.open({
                id: 'pop',
                title: '新增代金卡类型' ,
                css: 'width: 600px;',
                btnName: '保存',
                btnCall: 'cardType.edit.check();'
            });
        },

        check: function() {
            var error_msg = '';
            this.dt = E.getFormValues('item_form');

            if (E.isEmpty(this.dt.card_type))
                error_msg += '代金卡类型信息不能为空<br/>';

            if (error_msg != '') {
                E.alert(error_msg);
            } else {
                    E.confirm('您确认添加现金卡类型吗？', 'cardType.edit.execute');
            }

        },

        execute: function() {

            E.loadding.open('正在保存，请稍候...');

            E.ajax_post({
                url: '/invokingAjax-backend/company/cardType.ajax?operFlg=2',
                data: this.dt,
                call: 'cardType.edit.result'
            });

        },

        result: function( o ) {

            E.loadding.close();

            if (o.code == 200) {

                E.popup.close();
                document.getElementById('item_form').reset();

                E.alert(o.message, 2, 'cardType.load');
            } else {
                E.alert(o.message);
            }

        }

    },

    //重新加载表格
    load: function() {
        $("#flex").flexReload();
    }


};


</script>


</body>
</html>